package org.blog.tools;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Expression {

	public static boolean isValid(String str, int max, int min) {
		boolean valid = true;
		valid &= Expression.isRegular(str);
		valid &= str.length() <= max;
		valid &= str.length() >= min;
		return valid;
	}
	
	public static boolean isRegular(String string) {
		
		if(string == null) return false;
		Pattern p = Pattern.compile("[^a-z0-9 .,!]", Pattern.CASE_INSENSITIVE);
		Matcher m = p.matcher(string);
		return !m.find();
	}
}
